import "babel-polyfill";
function getComponent() {
    return import(/* webpackChunkName: "lodash" */ 'lodash').then(function(_){
        let element = document.createElement('div');

        element.innerHTML = _.join(['Hello', 'webpack'], ' ');

       let button = document.createElement('button');

       button.innerHTML = 'Click me and look at the console!';
       element.appendChild(button);

       button.onclick = function(e) {
           import(/* webpackChunkName: "print" */ './print').then(
               function (module) {
                   var print = module.default;

                   print();

                   $("#found_by_jquery").css("backgroundColor","red");
               });

       }
       return element;

    }).catch(function (error) {
        console.log(error);

    });
}

getComponent().then(function (component) {
    document.body.appendChild(component);
})